<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>”hexo学习日记“ | SuperXCR</title><meta name="author" content="SuperXCR"><meta name="copyright" content="SuperXCR"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Github Pages 搭建 Hexo 个人博客此处跟随蓝桥杯搭建的 hexo框架+Next主题1. 准备环境1234#前提git,nodejs已经安装git version #gitnode -v     #nodejsnpm -v      #npm,默认和node一起安装 2. 安装 Hexo在命令行输入执行以下命令 1npm install -g hexo-cli 安装 Hexo 完成后">
<meta property="og:type" content="article">
<meta property="og:title" content="”hexo学习日记“">
<meta property="og:url" content="https://liqur.xyz/SuperXCR/5a789e17.html">
<meta property="og:site_name" content="SuperXCR">
<meta property="og:description" content="Github Pages 搭建 Hexo 个人博客此处跟随蓝桥杯搭建的 hexo框架+Next主题1. 准备环境1234#前提git,nodejs已经安装git version #gitnode -v     #nodejsnpm -v      #npm,默认和node一起安装 2. 安装 Hexo在命令行输入执行以下命令 1npm install -g hexo-cli 安装 Hexo 完成后">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img2.baidu.com/it/u=1969408648,3814003583&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=450">
<meta property="article:published_time" content="2022-07-13T01:53:49.000Z">
<meta property="article:modified_time" content="2022-09-15T13:37:08.463Z">
<meta property="article:author" content="SuperXCR">
<meta property="article:tag" content="笔记">
<meta property="article:tag" content="hexo">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img2.baidu.com/it/u=1969408648,3814003583&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=450"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://liqur.xyz/SuperXCR/5a789e17.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '”hexo学习日记“',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-09-15 21:37:08'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.css" /><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-tag-plugins-plus@latest/lib/assets/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-tag-plugins-plus@latest/lib/tag_plugins.css" media="defer" onload="this.media='all'"><script src="https://cdn.cbd.int/hexo-butterfly-tag-plugins-plus@latest/lib/assets/carousel-touch.js"></script><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.2"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">16</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><hr/></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://img2.baidu.com/it/u=1969408648,3814003583&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=800&amp;h=450')"><nav id="nav"><span id="blog-info"><a href="/" title="SuperXCR"><span class="site-name">SuperXCR</span></a></span><div id="menus"><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">”hexo学习日记“</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-07-13T01:53:49.000Z" title="发表于 2022-07-13 09:53:49">2022-07-13</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-09-15T13:37:08.463Z" title="更新于 2022-09-15 21:37:08">2022-09-15</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="”hexo学习日记“"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="Github-Pages-搭建-Hexo-个人博客"><a href="#Github-Pages-搭建-Hexo-个人博客" class="headerlink" title="Github Pages 搭建 Hexo 个人博客"></a>Github Pages 搭建 Hexo 个人博客</h2><h4 id="此处跟随蓝桥杯搭建的-hexo框架-Next主题"><a href="#此处跟随蓝桥杯搭建的-hexo框架-Next主题" class="headerlink" title="此处跟随蓝桥杯搭建的 hexo框架+Next主题"></a>此处跟随蓝桥杯搭建的 hexo框架+Next主题</h4><h3 id="1-准备环境"><a href="#1-准备环境" class="headerlink" title="1. 准备环境"></a>1. 准备环境</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">#前提git,nodejs已经安装</span><br><span class="line">git version #git</span><br><span class="line">node -v     #nodejs</span><br><span class="line">npm -v      #npm,默认和node一起安装</span><br></pre></td></tr></table></figure>
<h3 id="2-安装-Hexo"><a href="#2-安装-Hexo" class="headerlink" title="2. 安装 Hexo"></a>2. 安装 Hexo</h3><p>在命令行输入执行以下命令</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g hexo-cli</span><br></pre></td></tr></table></figure>
<p>安装 Hexo 完成后，再执行下列命令，Hexo 将会在指定文件夹中新建所需要的文件。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo init blog</span><br><span class="line">cd blog</span><br><span class="line">npm install</span><br></pre></td></tr></table></figure>
<p>新建完成后，指定文件夹的目录如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">.</span><br><span class="line">├── scaffolds # 模版文件夹</span><br><span class="line">├── _config.yml # 网站的配置信息，您可以在此配置大部分的参数。</span><br><span class="line">├── package.json</span><br><span class="line">├── source  # 资源文件夹，除 _posts 文件，其他以下划线_开头的文件或者文件夹不会被编译打包到public文件夹</span><br><span class="line">|   ├── _drafts # 草稿文件</span><br><span class="line">|   └── _posts # 文章Markdowm文件</span><br><span class="line">└── themes  # 主题文件夹</span><br></pre></td></tr></table></figure>
<p>运行以下命令，预览效果：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo generate #生成文件</span><br><span class="line">hexo server #在本地server部署</span><br><span class="line">#默认在http://localhost:4000/访问</span><br></pre></td></tr></table></figure>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/59fbbf2a469bd0671a7f5ec3415e7444-0" alt="pic"></p>
<p>常见命令及简写</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">hexo generate ---&gt;  hexo g # 生成页面文件</span><br><span class="line">hexo server ---&gt; hexo s # 启动服务预览</span><br><span class="line">hexo s -p 8080 # 指定端口运行</span><br><span class="line">hexo deploy ---&gt; hexo d # 部署</span><br><span class="line">hexo clean # 清除缓存，若是网页正常情况下可以忽略这条命令</span><br></pre></td></tr></table></figure>
<h3 id="3-注册-Github"><a href="#3-注册-Github" class="headerlink" title="3. 注册 Github"></a>3. 注册 Github</h3><p>如果 Github 账号请先在<a target="_blank" rel="noopener" href="https://github.com/">Github</a>官网进行注册。注册完毕后，我们新建一个仓库：</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657675612090.png" alt="1657675612090"></p>
<p>注意：Github 仅能使用一个同名仓库的代码托管一个静态站点。</p>
<p>我这里已经创建过了，所以会变红</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657675531920.png" alt="1657675531920"></p>
<p><strong>注意：</strong> 仓库名必须是 <code>&lt;username&gt;.github.io</code> ，如果你的 github 名是 David，那么你的仓库名必须是 <code>David.github.io</code> 。</p>
<h3 id="4-配置-SSH-key"><a href="#4-配置-SSH-key" class="headerlink" title="4. 配置 SSH key"></a>4. 配置 SSH key</h3><p>要使用 git 工具首先要配置一下 SSH key，为部署本地博客到 Github 做准备。为什么要配置这个呢？因为你提交代码肯定要拥有你的 Github 权限才可以，但是直接使用用户名和密码太不安全了，所以我们使用 ssh key 来解决本地和服务器的连接问题</p>
<p>生成密钥：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -C &quot;邮件地址&quot;</span><br></pre></td></tr></table></figure>
<p><img src="https://doc.shiyanlou.com/courses/1552/1226977/ecdb245748bd37c1d598ca6191439c53-0" alt="pic"></p>
<p>执行以下命令查看密钥：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cat ~/.ssh/id_rsa.pub</span><br></pre></td></tr></table></figure>
<p><img src="https://doc.shiyanlou.com/courses/1552/1226977/86bf69bf2fc01b1e3b3cd171326d4dc6-0" alt="pic"></p>
<p>然后在 Github 添加刚刚生成的 SSH key，按以下步骤添加：</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657675875440.png" alt="1657675875440"></p>
<p>创建一个新的 SSH key，点击 <code>New SSH key</code> ，标题可以自定义，key 就填刚才生成的那一长串，确认创建后，在你的 SSH keys 列表里就会看到你刚刚添加的密钥。</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657675915489.png" alt="1657675915489"></p>
<p>执行命令 <code>ssh -T git@github.com</code>，确认并添加主机到本机 SSH 可信列表，执行命令后，需要输入 <code>yes</code>，若返回 <code>Hi xxx! You&#39;ve successfully authenticated, but GitHub does not provide shell access</code> 内容，则证明添加成功。</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657706722993.png" alt="pic"></p>
<h3 id="5-部署到-Github"><a href="#5-部署到-Github" class="headerlink" title="5. 部署到 Github"></a>5. 部署到 Github</h3><p>部署之前需要修改配置和安装部署插件。</p>
<p>首先打开项目根目录下的 <code>_config.yml</code> 配置文件配置参数。拉到文件末尾，填上如下配置：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line">  type: git</span><br><span class="line">  repo: 这里填入你之前在GitHub上创建仓库的完整路径</span><br><span class="line">  branch: master</span><br></pre></td></tr></table></figure>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202022-07-13%20093430.png" alt=""></p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657676174088.png" alt="1657676174088"></p>
<p>然后安装一个部署插件：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /home/project/blog # 切换到项目文件夹下</span><br><span class="line">npm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure>
<p>执行下面的命令设置 Github 的用户名和邮箱：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.email &quot;你的github邮箱&quot;</span><br><span class="line">git config --global user.name &quot;你的github名字&quot;</span><br></pre></td></tr></table></figure>
<h5 id="自动部署"><a href="#自动部署" class="headerlink" title="自动部署"></a>自动部署</h5><p>配置完成后，我们直接执行 <code>hexo d</code> 命令，即可开始自动部署，期间环境里会有一个登录的弹窗，点击打开后授权环境内访问你的 Github（正确执行窗口会变成 404，直接关闭即可）。然后就会自动把文件上传到仓库里。</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657706957090.png" alt="img"></p>
<p>稍等一会，在浏览器访问网址：<a target="_blank" rel="noopener" href="https://xn--6qqv7i14ofosyrb.github.io/">https://你的用户名.github.io</a> 就会看到你的博客了。有时候执行 <code>hexo -d</code> 会有延迟，需要等一会儿。</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657706995732.png" alt="pic"></p>
<p>博客搭好了，现在我们开始写文章，实验中只会对此简单介绍，详细的文档可以看 <a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/">hexo</a> 官网。</p>
<p>新建文章，输入以下命令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new &#x27;文章标题名&#x27;</span><br></pre></td></tr></table></figure>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707033460.png" alt="pic"></p>
<p>执行完成后可以在 <code>/source/_posts</code> 下看到一个 “hexo 学习日记.md” 的文章文件。<code>.md</code> 就是 Markdown 格式的文件，具体使用可以在网上查找一下，这里只会简单介绍。</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707079405.png" alt="pic"></p>
<p>打开文章输入以下内容：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"># 这是一级标题</span><br><span class="line"></span><br><span class="line">这一段是正文内容</span><br><span class="line"></span><br><span class="line">## 这是二级标题</span><br><span class="line"></span><br><span class="line">这是一段正文内容</span><br><span class="line"></span><br><span class="line">### 这是三级标题</span><br><span class="line"></span><br><span class="line">这是一段正文内容</span><br></pre></td></tr></table></figure>
<p>部署到 github，执行以下命令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo g -d</span><br></pre></td></tr></table></figure>
<p>注意：每一次想部署到 github，都需要执行这条命令，后面不再进行提示。</p>
<p>这个时候在 github 的如下目录中，就会有我们新建的文章文件了。</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657677821104.png" alt="1657677821104"></p>
<p>然后打开博客，就能看到我们新建的文章内容。</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707156862.png" alt="pic"></p>
<h3 id="6-主题设置"><a href="#6-主题设置" class="headerlink" title="6. 主题设置"></a>6. 主题设置</h3><p>网上有很多好看简洁的 Hexo 主题可以更换，下面将以 Next 这款我喜欢的主题为例子，进行更换。</p>
<p>首先你需要找到你喜欢的主题下载地址，这里介绍一下<a target="_blank" rel="noopener" href="https://github.com/iissnan/hexo-theme-next">next 主题</a>。点击<code>Clone or download</code> 后将链接复制下来，输入以下命令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone https://github.com/iissnan/hexo-theme-next themes/next</span><br></pre></td></tr></table></figure>
<p>找到 Hexo 文件的位置，进入 themes 文件夹内，这个文件夹就是用来放 hexo 主题的位置的。下载完成后，你就可以看到 themes 文件夹下出现了一个新的名为 next 文件夹，这个就是我们刚刚下载的主题。</p>
<p>打开 <code>_config.yml</code> 这个文件，找打 <code>theme</code> 属性，更改属性值：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">theme: next</span><br></pre></td></tr></table></figure>
<p>并且修改一下作者，网页标题等信息。</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707211326.png" alt="pic"></p>
<p>执行如下命令，先在环境进行测试，如果运行成功，执行命令到博客上。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hexo g</span><br><span class="line">hexo server</span><br></pre></td></tr></table></figure>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707243289.png" alt="pic"></p>
<p>这样 next 主题设置就成功了。</p>
<h3 id="7-主题风格设置"><a href="#7-主题风格设置" class="headerlink" title="7. 主题风格设置"></a>7. 主题风格设置</h3><p>Next 提供了四种主题，可以在主题配置文件 <code>blog/themes/next/_config.yml</code> 文件中进行选择，分别是 <code>Muse</code>、<code>Mist</code>、<code>Pisces</code>、<code>Gemini</code>：</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707269911.png" alt="pic"></p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707300399.png" alt="pic"></p>
<p>Next 主题默认只有两个菜单，如果要增加菜单，在<code>themes/next/_config.yml</code>中修改配置：</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707341390.png" alt="pic"></p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707369863.png" alt="pic"></p>
<h3 id="8-添加评论功能"><a href="#8-添加评论功能" class="headerlink" title="8. 添加评论功能"></a>8. 添加评论功能</h3><p>使用 LeanCloud 作为服务后台，先注册一个 LeanCloud 账号： <a target="_blank" rel="noopener" href="https://links.jianshu.com/go?to=https%3A%2F%2Fleancloud.cn%2F">Leancloud 官网</a>。创建一个应用，名字自定义，在应用中的存储中创建一个 Class，名字叫做<code>Counter</code>，权限设置为无限制：</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707401766.png" alt="pic"></p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707425190.png" alt="pic"></p>
<p>在<code>themes/next/_config.yml</code>中修改配置，搜索 <code>valine</code>，开启 <code>valine</code>，设置 <code>enable</code> 为 <code>true</code>，填上 id 和 key。</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707469185.png" alt="pic"></p>
<p>刷新，效果如图：</p>
<p><img src="http://rextizycj.hd-bkt.clouddn.com/1657707528845.png" alt="pic"></p>
<p>最后按照上面学习的步骤，部署到自己的博客上就可以了。</p>
<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><p>通过这门课我们学习了以下内容：</p>
<ul>
<li>准备环境</li>
<li>安装 Hexo</li>
<li>注册 Github</li>
<li>配置 SSH key</li>
<li>部署到 Github</li>
<li>开始写作</li>
<li>主题设置</li>
<li>七牛实现图床</li>
<li>个性化主题</li>
<li>添加评论功能</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://liqur.xyz">SuperXCR</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://liqur.xyz/SuperXCR/5a789e17.html">https://liqur.xyz/SuperXCR/5a789e17.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://liqur.xyz" target="_blank">SuperXCR</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E7%AC%94%E8%AE%B0/">笔记</a><a class="post-meta__tags" href="/tags/hexo/">hexo</a></div><div class="post_share"><div class="social-share" data-image="https://img2.baidu.com/it/u=1969408648,3814003583&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=800&amp;h=450" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/SuperXCR/a574217b.html" title="Markdown基本语法"><img class="cover" src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/Markdown.jpeg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Markdown基本语法</div></div></a></div><div class="next-post pull-right"><a href="/SuperXCR/bf9da926.html" title="”Test“"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">”Test“</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">SuperXCR</div><div class="author-info__description">今日事，今日毕</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">16</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Github-Pages-%E6%90%AD%E5%BB%BA-Hexo-%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2"><span class="toc-number">1.</span> <span class="toc-text">Github Pages 搭建 Hexo 个人博客</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%AD%A4%E5%A4%84%E8%B7%9F%E9%9A%8F%E8%93%9D%E6%A1%A5%E6%9D%AF%E6%90%AD%E5%BB%BA%E7%9A%84-hexo%E6%A1%86%E6%9E%B6-Next%E4%B8%BB%E9%A2%98"><span class="toc-number">1.0.1.</span> <span class="toc-text">此处跟随蓝桥杯搭建的 hexo框架+Next主题</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-%E5%87%86%E5%A4%87%E7%8E%AF%E5%A2%83"><span class="toc-number">1.1.</span> <span class="toc-text">1. 准备环境</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E5%AE%89%E8%A3%85-Hexo"><span class="toc-number">1.2.</span> <span class="toc-text">2. 安装 Hexo</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-%E6%B3%A8%E5%86%8C-Github"><span class="toc-number">1.3.</span> <span class="toc-text">3. 注册 Github</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-%E9%85%8D%E7%BD%AE-SSH-key"><span class="toc-number">1.4.</span> <span class="toc-text">4. 配置 SSH key</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-%E9%83%A8%E7%BD%B2%E5%88%B0-Github"><span class="toc-number">1.5.</span> <span class="toc-text">5. 部署到 Github</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2"><span class="toc-number">1.5.0.1.</span> <span class="toc-text">自动部署</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-%E4%B8%BB%E9%A2%98%E8%AE%BE%E7%BD%AE"><span class="toc-number">1.6.</span> <span class="toc-text">6. 主题设置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-%E4%B8%BB%E9%A2%98%E9%A3%8E%E6%A0%BC%E8%AE%BE%E7%BD%AE"><span class="toc-number">1.7.</span> <span class="toc-text">7. 主题风格设置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#8-%E6%B7%BB%E5%8A%A0%E8%AF%84%E8%AE%BA%E5%8A%9F%E8%83%BD"><span class="toc-number">1.8.</span> <span class="toc-text">8. 添加评论功能</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%80%BB%E7%BB%93"><span class="toc-number">1.9.</span> <span class="toc-text">总结</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/7f8be62d.html" title="你不会还不会安装Maven吧"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/SuperXCR/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230310162508.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="你不会还不会安装Maven吧"/></a><div class="content"><a class="title" href="/SuperXCR/7f8be62d.html" title="你不会还不会安装Maven吧">你不会还不会安装Maven吧</a><time datetime="2023-03-10T09:57:23.000Z" title="发表于 2023-03-10 17:57:23">2023-03-10</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/c24675b4.html" title="MySQL"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/MySQL%E9%85%8D%E7%BD%AE/mysql.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MySQL"/></a><div class="content"><a class="title" href="/SuperXCR/c24675b4.html" title="MySQL">MySQL</a><time datetime="2022-11-21T06:48:00.000Z" title="发表于 2022-11-21 14:48:00">2022-11-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/bfa56f5e.html" title="Navicat_Premium_16破解"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/s1.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Navicat_Premium_16破解"/></a><div class="content"><a class="title" href="/SuperXCR/bfa56f5e.html" title="Navicat_Premium_16破解">Navicat_Premium_16破解</a><time datetime="2022-09-26T02:55:58.000Z" title="发表于 2022-09-26 10:55:58">2022-09-26</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/b2444a9.html" title="MySQL安装配置"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/MySQL%E9%85%8D%E7%BD%AE/mysql.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MySQL安装配置"/></a><div class="content"><a class="title" href="/SuperXCR/b2444a9.html" title="MySQL安装配置">MySQL安装配置</a><time datetime="2022-09-24T03:30:42.000Z" title="发表于 2022-09-24 11:30:42">2022-09-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/SuperXCR/a219e661.html" title="羊了个羊17最新版"><img src="https://liqur-1309874423.cos.ap-shanghai.myqcloud.com/s6.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="羊了个羊17最新版"/></a><div class="content"><a class="title" href="/SuperXCR/a219e661.html" title="羊了个羊17最新版">羊了个羊17最新版</a><time datetime="2022-09-16T05:18:03.000Z" title="发表于 2022-09-16 13:18:03">2022-09-16</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By SuperXCR</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><script>
    // 全局变量声明区域
    var fdata = {
      apiurl: 'https://hexo-friendcircle-api-ai9d4hwad-anzhiyu-c.vercel.app/api',
      initnumber: 20, //【可选】页面初始化展示文章数量
      stepnumber: 10, //【可选】每次加载增加的篇数
      error_img: 'https://npm.elemecdn.com/akilar-candyassets/image/404.gif' //【可选，头像图片加载失败时的默认头像】
    }
    //存入本地存储
    localStorage.setItem("fdatalist",JSON.stringify(fdata))
    </script>
    <script defer src="https://npm.elemecdn.com/hexo-filter-fcircle/assets/js/fetch.min.js"></script><script data-pjax>
  function butterfly_clock_anzhiyu_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>';
    console.log('已挂载butterfly_clock_anzhiyu')
    if(parent_div_git) {
      parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var qweather_key = 'b16a1fa0e63c46a4b8f28abfb06ae3fe';
  var gaud_map_key = 'e2b04289e870b005374ee030148d64fd&s=rsv3';
  var baidu_ak_key = 'undefined';
  var flag = 0;
  var clock_rectangle = '112.982279,28.19409';
  var clock_default_rectangle_enable = 'false';

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_clock_anzhiyu_injector_config();
  }
  else if (epage === cpage){
    butterfly_clock_anzhiyu_injector_config();
  }
  </script><script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script><script data-pjax src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.js"></script><script async src="/js/ali_font.js"></script><!-- hexo injector body_end end --></body></html>